<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <title>转诊-51问医生</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
{{--    <script src="{{url('/js/rem.js')}}"></script>--}}
    {{--<script src="{{url('/js/jquery.min.js')}}" type="text/javascript"></script>--}}
    {{--<link rel="stylesheet" type="text/css" href="{{url('./css/base.css')}}"/>--}}
    {{--<link rel="stylesheet" type="text/css" href="{{url('./css/page.css')}}"/>--}}
    {{--<link rel="stylesheet" type="text/css" href="{{url('./css/all.css')}}"/>--}}
    {{--<link rel="stylesheet" type="text/css" href="{{url('./css/loaders.min.css')}}"/>--}}
    {{--<link rel="stylesheet" type="text/css" href="{{url('./css/loading.css')}}"/>--}}
    <script type="text/javascript" src="{{url('./js/jquery-1.8.3.min.js')}}" ></script>

    <link rel="stylesheet" href="{{url('css/weui.min.css')}}">
    <link rel="stylesheet" href="{{url('css/jquery-weui.min.css')}}">

    {{--<link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.2/style/weui.min.css">--}}
    {{--<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.min.css">--}}

    <!-- Noty 提示框的js集成 -->
    <script src="{{ url('vendor/noty-2.2.9/packaged/jquery.noty.packaged.js') }}"></script>
    <script src="{{ url('vendor/noty-2.2.9/themes/bootstrap.js') }}"></script>
    <script src="{{ url('vendor/noty-2.2.9/options.js') }}"></script>

    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
    <script src="{{url('js/jquery-weui.min.js')}}"></script>
</head>
<body>
<header class="mui-bar mui-bar-nav report-header box-s" id="header" style="background-color: #000000;padding: 3% 3%;text-align: center">
    <a href="javascript:history.go(-1)"><i class="iconfont icon-fanhui fl" style="color: white"></i></a>
    <p style="color: #FFFFFF">确认转诊信息</p>
</header>

<div class="weui-form-preview">
    @if(!is_null($referral->order_num))
    <div class="weui-form-preview__hd">
        <label class="weui-form-preview__label">转诊费用</label>
        <em class="weui-form-preview__value">¥{{$referral->amount}}</em>
    </div>
    @endif
    <div class="weui-form-preview__bd">
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">病人姓名</label>
            <span class="weui-form-preview__value">@if($patient){{$patient->realname}}@endif</span>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">病人生日</label>
            <span class="weui-form-preview__value">@if($patient){{$patient->birthday}}@endif</span>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">联系病人</label>
            <span class="weui-form-preview__value">@if($patient){{$patient->phone}}@endif</span>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">转出医院</label>
            <span class="weui-form-preview__value">@if($doctor){{$doctor->hospital}}-{{$doctor->doc_name}}@endif</span>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">诊断描述</label>
            <span class="weui-form-preview__value">@if($patient){{$patient->desc}}@endif</span>
        </div>
    </div>
    <div class="weui-form-preview__ft">
        <input type="hidden" id="referral_id" value="{{$referral->id}}">
        <a class="weui-form-preview__btn weui-form-preview__btn_default" href="javascript:" style="color: red" id="btn_no">婉拒</a>
        <button type="submit" class="weui-form-preview__btn weui-form-preview__btn_primary" href="javascript:" id="btn_yes">确认</button>
    </div>
</div>
<script>
    $(function () {
        $(document).on("click", "#btn_yes", function() {
            var referralId = $("#referral_id").val();
            $.confirm("确定同意转诊吗？", function() {
                $.ajax({
                    url:"{{route('Api.Doctor.confirmReferral')}}",
                    type:"post",
                    dataType:"json",
                    data:{referral_id:referralId,status:2},
                    success:function (obj) {
                        if(obj.level == "success"){
                            $.alert("转诊已确认");
                        }else {
                            $.alert(obj.message);
                        }
                    },
                    error:function (obj) {
                        console.log(obj);
                    }
                });
            }, function() {
                console.log("取消");
            });
        });

        $(document).on("click", "#btn_no", function() {
            var referralId = $("#referral_id").val();
            $.prompt({
                title: "请输入不接诊原因",
                onOK: function(text) {
                    $.ajax({
                        url:"{{route('Api.Doctor.confirmReferral')}}",
                        type:"post",
                        dataType:"json",
                        data:{referral_id:referralId,status:-1,reason:text},
                        success:function (obj) {
                            if(obj.level == "success"){
                                $.alert("转诊已婉拒");
                            }else {
                                $.alert(obj.message);
                            }
                        },
                        error:function (obj) {
                            console.log(obj);
                        }
                    });
                },
                onCancel: function() {
                    console.log("取消了");
                },
            });
        });
    })
</script>
</body>
</html>